package cz.pproproj.aaservice.aasdbmodule;

import cz.pproproj.aaservice.aasbllmodule.authorization.AuthorizationModuleAccess;
import cz.pproproj.aaservice.guimodule.model.AuthorizationRole;
import cz.pproproj.aaservice.guimodule.model.AuthorizationUser;

import java.util.List;
import java.util.Map;

/**
 * @author David
 * @since 18. 1. 2015
 */
public class AuthorizationModuleAccessImpl implements AuthorizationModuleAccess {

    private DbManagement _dbManagement = AuthorizationModuleContext.getInstance().getDbManagement();

    @Override
    public List<AuthorizationRole> getRolesFromUser(AuthorizationUser user) {
        return _dbManagement.getRolesFromUser(user);
    }

    @Override
    public List<AuthorizationRole> getAllRoles() {
        return _dbManagement.getAllRoles();
    }

    @Override
    public boolean removeRole(AuthorizationRole role) {
        return _dbManagement.removeRole(role);
    }

    @Override
    public boolean addRole(AuthorizationRole role) {
        return _dbManagement.addRole(role);
    }

    @Override
    public boolean removeMapping(AuthorizationUser user, List<AuthorizationRole> roles) {
        return _dbManagement.removeMapping(user, roles);
    }

    @Override
    public boolean addMapping(AuthorizationUser user, List<AuthorizationRole> roles) {
        return _dbManagement.addMapping(user, roles);
    }

    @Override
    public boolean authorize(AuthorizationUser user, AuthorizationRole role) {
        return _dbManagement.authorize(user, role);
    }

    @Override
    public Map<AuthorizationUser, List<AuthorizationRole>> getAllMappings() {
        return _dbManagement.getAllMappings();
    }
}
